package com.woniuxy.house.provider;

import com.woniuxy.house.entity.HouseDetail;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.jdbc.SQL;

@Slf4j
public class HouseDetailSqlProvider {
    public String update(HouseDetail houseDetail) {
        String sql = new SQL() {
            {
                UPDATE("house_detail");
                if (houseDetail.getHouseDescription() != null) {
                    SET("house_description=#{houseDescription}");
                }
                if (houseDetail.getAfforest()!= null) {
                    SET("afforest=#{afforest}");
                }
                if (houseDetail.getContract()!= null) {
                    SET("contract=#{contract}");
                }
                if (houseDetail.getFloor()!= null) {
                SET("floor=#{floor}");
            }
                if (houseDetail.getProviderHot()!= null) {
                SET("provider_hot=#{providerHot}");
            }
                if (houseDetail.getLift()!= null) {
                    SET("lift=#{lift}");
                }
                if (houseDetail.getSituation()!= null) {
                    SET("situation=#{situation}");
                }
                if (houseDetail.getSituation()!= null) {
                    SET("situation=#{situation}");
                }
                if (houseDetail.getYear()!= null) {
                    SET("year=#{year}");
                }
				if (houseDetail.getConfig()!= null) {
					SET("config=#{config}");
				}
				if (houseDetail.getCheckInTime()!= null) {
					SET("check_in_time=#{checkInTime}");
				}
				if (houseDetail.getLease()!= null) {
					SET("lease=#{lease}");
				}
                WHERE("id=#{id}");
            }
        }.toString();
        log.debug("sql:{}",sql);
        return sql;
    }
}
